"use strict";
cc._RF.push(module, '01570fie7FEJLC04rT+Tj2v', 'drawRecord');
// scripts/O1ModuleRes/control/o1DrawBoard/drawRecord.ts

"use strict";
// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var gameEngine_1 = require("../../../engines/gameEngine");
var drawDetail_1 = require("./drawDetail");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var drawRecord = /** @class */ (function (_super) {
    __extends(drawRecord, _super);
    function drawRecord() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.drawDetail = null;
        _this.svContentList = null;
        _this.m_drawClass = null;
        return _this;
        // update (dt) {}
    }
    drawRecord.prototype.onLoad = function () {
        gameEngine_1.default.off('drawRecord.OnEditDraw');
        gameEngine_1.default.off('drawRecord.OnDeleteDraw');
        gameEngine_1.default.on('drawRecord.OnEditDraw', this.OnEditDraw.bind(this));
        gameEngine_1.default.on('drawRecord.OnDeleteDraw', this.OnDeleteDraw.bind(this));
    };
    drawRecord.prototype.start = function () {
    };
    drawRecord.prototype.bindDrawInterface = function (drawClass) {
        this.m_drawClass = drawClass;
        this.OnLoadDrawList();
    };
    drawRecord.prototype.OnEditDraw = function (nameKey) {
        gameEngine_1.default.emit('o1DrawBoard.OnEditDraw', nameKey);
        this.OnBtnExit();
    };
    drawRecord.prototype.OnDeleteDraw = function (nameKey) {
        var _this = this;
        gameEngine_1.default.getModules().uiControlModule.showDialogBox("\u5220\u9664\u6587\u4EF6", "\u5220\u9664\u540E\u4E0D\u53EF\u6062\u590D,\u662F\u5426\u5220\u9664<" + nameKey + ">?", true, function (isOk) {
            if (isOk) {
                gameEngine_1.default.emit('o1DrawBoard.OnDeleteDraw', nameKey);
                //刷新
                _this.svContentList.destroyAllChildren();
                _this.scheduleOnce(_this.OnLoadDrawList.bind(_this));
                //
                // this.OnLoadDrawList();
            }
        }, this.node, '删除', '取消');
    };
    drawRecord.prototype.OnLoadDrawList = function () {
        gameEngine_1.default.getModules().uiControlModule.showLoading(this.node, '正在加载画册');
        //
        var dataInfo = this.m_drawClass.getAllData();
        for (var k in dataInfo) {
            var data = dataInfo[k];
            //
            var node = cc.instantiate(this.drawDetail);
            this.svContentList.addChild(node);
            var com = node.getComponent(drawDetail_1.default);
            com.setInfo(data);
        }
        gameEngine_1.default.getModules().uiControlModule.hideLoading();
    };
    drawRecord.prototype.OnBtnExit = function () {
        this.svContentList.destroyAllChildren();
        this.node.destroy();
    };
    __decorate([
        property(cc.Prefab)
    ], drawRecord.prototype, "drawDetail", void 0);
    __decorate([
        property(cc.Node)
    ], drawRecord.prototype, "svContentList", void 0);
    drawRecord = __decorate([
        ccclass
    ], drawRecord);
    return drawRecord;
}(cc.Component));
exports.default = drawRecord;

cc._RF.pop();